package com.tandashi.springbootstudy01.enums;

import java.util.Arrays;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;

public enum UserType implements BaseIntegerEnum {
    Unregistered(0,"未注册"),Senior(1,"高级会员"),Ordinary(2,"普通会员"),OfficeStaff(3,"内勤"),CounterOfficeStaff(4,"柜面内勤"),
    RenewalAgent(5,"续收专员"),ElecAgent(6,"电商专员"),Customer95589(7,"95589用户"),TptUser(8,"太平通用户"),ADV_PAY_SUPPLIER(9,"垫付供应商");

    private int value;
    private String desc;

    UserType(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    @Override
    public int getCode() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static UserType fromCode(Integer code){
        return  codeUserTypeMap.get(code);
    }

    private static final Map<Integer,UserType> codeUserTypeMap = Arrays.stream(UserType.values()).collect(Collectors.toMap(UserType::getCode, Function.identity()));

}
